package io.kimmking.dubbo.common.balance.unit;

import io.kimmking.dubbo.common.balance.LoadBalance;
import io.kimmking.spi.ExtensionLoader;

import java.util.List;

public class BalanceUnit {

    /**
     *
     * @param upstreams 服务器列表
     * @param implKey META-INF目录下的接口文件里实现类对应的Key值
     * @param from_ip 客户端的IP信息
     * @return
     * @throws Exception
     */
    public static String selector(final List<String> upstreams, final String implKey, final String from_ip) throws Exception {
        LoadBalance loadBalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getJoin(implKey);
        return loadBalance.select(upstreams, from_ip);
    }



}
